//日报绘制1
function drawdaychart1(chart, awake, max) {
  let temp = ""
  if (languageData.lab_1 == "Profondeur") {
    temp = "26%"
  } else {
    temp = "16%"
  }
  option1 = {
    title: {
      text: languageData.lab_3,
      left: '0%',
      top: '42%',
      textStyle: {
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'DM Sans',
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)"
      },
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'line',
        lineStyle: {
          color: '#C9D8E3',
          opacity: 0.5,
        },
      },
      formatter: function (value) {
        // console.log(value)
        let tempdata = value[0].data[1];
        if (tempdata == 3) {
          return (
            value[0].axisValueLabel.substring(0, 5) +
            '<br/>' +
            '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#CAD7D6;"></span > ' +
            'Awake'
          );
        } else {
        }
      },
    },
    grid: {
      top: '10%',
      right: '5%',
      left: temp,
      bottom: '0%',
    },
    xAxis: {
      type: 'time',
      boundaryGap: false,
      axisTick: {
        show: false,
      },
      splitNumber: 5,
      axisLabel: {
        show: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        //opacity: 0.5,
        showMaxLabel: true,
        showMinLabel: true,
        fontSize: getDpr(),
      },
      axisLine: {
        lineStyle: {
          color: '#F2F6FE',
          width: 1,
          //opacity: 0.5,
        },
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#F2F6FE',
          //opacity: 0.3,
        },
      },
    },
    yAxis: [
      {
        // name: 'dB',
        type: 'value',
        splitNumber: 100000,
        nameLocation: 'end',
        nameTextStyle: {
          fontSize: getDpr() * 1.2,
          padding: 2,
          align: 'center',
        },
        max: max,
        min: 0,
        axisLabel: {
          formatter: '{value}',
          showMinLabel: false,
          showMaxLabel: false,
          fontSize: 14,
          fontWeight: 'bold',
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: '#F2F6FE',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1,
            type: 'dashed',
            color: '#CAD7D6',
            //opacity: 0.6,
          },
        },
        splitLine: {
          lineStyle: {
            color: '#CAD7D6',
            //opacity: 0.3,
          },
        },
      },
    ],
    series: [
      {
        data: awake,
        type: 'bar',
        barCategoryGap: '0%',
        smooth: true,
        lineStyle: {
          color: '#CAD7D6',
          width: 1,
        },
        itemStyle: {
          color: '#CAD7D6',
        },
      },
    ],
  };
  chart.setOption(option1);
  chart.resize();
}
//日报绘制2
function drawdaychart2(chart, awake, max) {
  let temp = ""
  if (languageData.lab_1 == "Profondeur") {
    temp = "26%"
  } else {
    temp = "16%"
  }
  option1 = {
    title: {
      text: languageData.lab_2,
      left: '0%',
      top: '38%',
      textStyle: {
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'DM Sans',
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
      },
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'line',
        lineStyle: {
          color: '#C9D8E3',
          opacity: 0.5,
        },
      },
      formatter: function (value) {
        let tempdata = value[0].data[1];
        if (tempdata == 2) {
          return (
            value[0].axisValueLabel.substring(0, 5) +
            '<br/>' +
            '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:rgba(75, 168, 142, 1);"></span > ' +
            'Light'
          );
        } else {
        }
      },
    },
    grid: {
      top: '0%',
      right: '5%',
      left: temp,
      bottom: '0%',
    },
    xAxis: {
      type: 'time',
      boundaryGap: false,
      axisTick: {
        show: false,
      },
      splitNumber: 5,
      axisLabel: {
        show: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        //opacity: 0.5,
        showMaxLabel: true,
        showMinLabel: true,
        fontSize: getDpr(),
      },
      axisLine: {
        lineStyle: {
          color: '#F2F6FE',
          width: 1.3,
          //opacity: 0.5,
        },
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#F2F6FE',
          //opacity: 0.3,
        },
      },
    },
    yAxis: [
      {
        // name: 'dB',
        type: 'value',
        splitNumber: 1,
        nameLocation: 'end',
        nameTextStyle: {
          fontSize: getDpr() * 1.2,
          padding: 2,
          align: 'center',
        },
        max: max,
        axisLabel: {
          formatter: '{value}',
          showMinLabel: false,
          fontSize: getDpr(),
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: '#F2F6FE',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1.5,
            type: 'dashed',
            color: '#F2F6FE',
            //opacity: 0.6,
          },
        },
        splitLine: {
          lineStyle: {
            color: '#F2F6FE',
            //opacity: 0.3,
          },
        },
      },
    ],
    series: [
      {
        data: awake,
        type: 'bar',
        barCategoryGap: '0%',
        smooth: true,
        lineStyle: {
          color: '#4BA88E',
          width: 1,
        },
        itemStyle: {
          color: '#4BA88E',
        },
      },
    ],
  };
  chart.setOption(option1);
  chart.resize();
}
//日报绘制3
function drawdaychart3(chart, deep, max) {
  let temp = ""
  if (languageData.lab_1 == "Profondeur") {
    temp = "26%"
  } else {
    temp = "16%"
  }
  option1 = {
    title: {
      text: languageData.lab_1,
      left: '0%',
      top: '28%',
      textStyle: {
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'DM Sans',
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
      },
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'line',
        lineStyle: {
          color: '#C9D8E3',
          opacity: 0.5,
        },
      },
      formatter: function (value) {
        let tempdata = value[0].data[1];

        if (tempdata == 1) {
          return (
            value[0].axisValueLabel.substring(0, 5) +
            '<br/>' +
            '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:rgba(38, 84, 166, 1);"></span > ' +
            'Deep'
          );
        } else {
        }
      },
    },
    grid: {
      top: '0%',
      right: '5%',
      left: temp,
      bottom: '24%',
    },
    xAxis: {
      type: 'time',
      boundaryGap: false,
      axisTick: {
        show: false,
      },
      // splitNumber: 28060,
      axisLabel: {
        show: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        //opacity: 0.5,
        showMaxLabel: false,
        showMinLabel: false,
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'DM Sans',
        formatter: function (value) {
          var date = new Date(value);
          var y = date.getFullYear();
          var m = date.getMonth() + 1;
          var d = date.getDate();
          var h = date.getHours();
          var min = date.getMinutes();
          var s = date.getSeconds();
          var re = '';
          var temp = 0;
          min = min > 9 ? min : '0' + min;
          if (h > 12) {
            if (timetype == 12) {
              h = h - 12;
              temp = h;
              re = h + 'PM';
              h = h + ':' + min + 'PM';
              if (temp != 0 && temp % 2 == 0) {
                if (h.substring(h.length - 4, h.length - 2) == '00') {
                  if (!tmparr.includes(re)) {
                    tmparr.push(re);
                    return re;
                  }
                  return re;
                }
              }
            } else {
              temp = h;
              re = h;
              h = h + ':' + min;
              // if (temp != 0 && temp % 2 == 0) {
              if (!tmparr.includes(re)) {
                tmparr.push(re);
                return re;
              }
              return h;
              // }
            }
          } else {
            if (h == 0) {
              if (timetype == 12) {
                h = 12;
                temp = h;
                re = h + 'AM';
                h = h + ':' + min + 'AM';
                if (temp != 0 && temp % 2 == 0) {
                  if (h.substring(h.length - 4, h.length - 2) == '00') {
                    if (!tmparr.includes(re)) {
                      tmparr.push(re);
                      return re;
                    }
                    return re;
                  }
                }
              } else {
                temp = h;
                re = h;
                h = h + ':' + min;
                // if (temp != 0 && temp % 2 == 0) {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                return h;
                // }
              }
            } else {
              if (timetype == 12) {
                temp = h;
                re = h + 'AM';
                h = h + ':' + min + 'AM';
                if (temp != 0 && temp % 2 == 0) {
                  if (h.substring(h.length - 4, h.length - 2) == '00') {
                    if (!tmparr.includes(re)) {
                      tmparr.push(re);
                      return re;
                    }
                    return re;
                  }
                }
              } else {
                re = h;
                h = h + ':' + min;
                // if (temp != 0 && temp % 2 == 0) {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                return h;
                // }
              }
            }
          }
        },
      },
      axisLine: {
        lineStyle: {
          color: '#F2F6FE',
          width: 1.3,
          //opacity: 0.5,
        },
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#F2F6FE',
          //opacity: 0.3,
        },
      },
    },
    yAxis: [
      {
        // name: 'dB',
        type: 'value',
        splitNumber: 1,
        nameLocation: 'end',
        nameTextStyle: {
          fontSize: getDpr() * 1.2,
          padding: 2,
          align: 'center',
        },
        max: max,
        axisLabel: {
          formatter: '{value}',
          showMinLabel: false,
          fontSize: getDpr(),
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: '#F2F6FE',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1,
            type: 'dashed',
            color: '#F2F6FE',
            //opacity: 0.6,
          },
        },
        splitLine: {
          lineStyle: {
            color: '#F2F6FE',
            //opacity: 0.3,
          },
        },
      },
    ],
    series: [
      {
        data: deep,
        type: 'bar',
        barCategoryGap: '0%',
        smooth: true,
        lineStyle: {
          color: '#2D5CB4',
          width: 1,
        },
        itemStyle: {
          color: 'rgba(38, 84, 166, 1)',
        },
      },
    ],
  };
  chart.setOption(option1);
  chart.resize();
}
//周/月报整体图表
function drawweekchart(chart, deep, deep2, light, light2, awake, awake2, time, interval, max) {
  console.log('time===>', time)
  let tempinterval = 0;
  if (stage == 'week') {
    tempinterval = 1;
  } else if (stage == 'month') {
    tempinterval = 10;
  } else {
    tempinterval = 120;
  }
  option2 = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'none',
      },
      formatter: function (value) {
        //console.log(value)
        var Monthtemp = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Spt", "Oct", "Nov", "Dec"]
        let deep = value[4]
        let light = value[2]
        let awake = value[0]
        let deepvalue
        let lightvalue
        let awakevalue
        if (deep.data > 60) {
          deepvalue = Math.floor(deep.data / 60) + " h " + deep.data % 60 + " min"
        } else {
          deepvalue = deep.data + " min"
        }
        if (light.data > 60) {
          lightvalue = Math.floor(light.data / 60) + " h " + light.data % 60 + " min"
        } else {
          lightvalue = light.data + " min"
        }
        if (awake.data > 60) {
          awakevalue = Math.floor(awake.data / 60) + " h " + awake.data % 60 + " min"
        } else {
          awakevalue = awake.data + " min"
        }

        if (stage == 'week') {
          let tempdate = deep.axisValue.split('/')
          let tempdate_1 = parseInt(tempdate[0])
          if (deep.data == "-") {
            return 'Sleep report ' + '<br/>' + 'not collected.'
          } else {
            return Monthtemp[tempdate_1 - 1] + ' ' + tempdate[1] + "<br/>" + deep.marker + deepvalue + "<br/>" + light.marker + lightvalue + "<br/>" + awake.marker + awakevalue
          }
        } else if (stage == 'month') {
          let tempdate = deep.axisValue.split('/')
          let tempdate_1 = parseInt(tempdate[0])
          if (deep.data == "-") {
            return 'Sleep report ' + '<br/>' + 'not collected.'
          } else {
            return Monthtemp[tempdate_1 - 1] + ' ' + tempdate[1] + "<br/>" + ' ' + deep.marker + deepvalue + "<br/>" + light.marker + lightvalue + "<br/>" + awake.marker + awakevalue
          }
        } else {
          let tempdate = deep.axisValue.split('/')
          let tempdate_1 = parseInt(tempdate[0])
          if (deep.data == "-") {
            return 'Sleep report ' + '<br/>' + 'not collected.'
          } else {
            return Monthtemp[tempdate_1 - 1] + ' ' + tempdate[1] + "<br/>" + ' ' + deep.marker + deepvalue + "<br/>" + light.marker + lightvalue + "<br/>" + awake.marker + awakevalue
          }
        }
      }
    },
    grid: {
      top: '12%',
      right: '3%',
      bottom: '10%',
    },
    xAxis: {
      type: 'category',
      data: time,
      boundaryGap: false,
      offset: 0,
      axisTick: {
        show: false,
      },
      splitNumber: 4,
      axisLabel: {
        formatter: function (value, index) {
          console.log('stage===>', value)
          let temp = [];
          temp.push(index);
          const count = temp[temp.length - 1];
          if (index === 0) {
            if (stage == 'year') {
              console.log('stage===>', value)
              let num = parseInt(value.substring(0, 2));
              return '            ' + MonthArr[num - 1];
            } else {
              return '            ' + value;
            }
          } else if (index === count) {
            if (stage == 'year') {
              let num = parseInt(value.substring(0, 2));
              return MonthArr[num - 1] + '            ';
            } else {
              return value + '            ';
            }
          } else {
            if (stage == 'year') {
              let num = parseInt(value.substring(0, 2));
              return MonthArr[num - 1];
            } else {
              return value;
            }
          }
        },
        showMaxLabel: true,
        showMinLabel: true,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        //opacity: 0.5,
        interval: tempinterval,
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'DM Sans',
        // align: 'left',
        show: false,
      },
      axisLine: {
        lineStyle: {
          color: '#EFF0F0',
          width: 1.3,
          //opacity: 0.5,
        },
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#EFF0F0',
          //opacity: 0.3,
        },
      },
    },
    yAxis: [
      {
        // max: 100,
        name: '',
        nameLocation: 'end',
        nameTextStyle: {
          fontSize: getDpr() * 1.2,
          padding: 2,
          align: 'center',
        },
        splitNumber: 3,
        // data: [1, 2, 3, 4, 5, 6, 7, 8],
        type: 'value',
        axisLabel: {
          formatter: function (value) {
            let a = Math.ceil(value / 60);
            return a;
          },
          fontSize: 14,
          fontWeight: '400',
          // color: '#093147',
          color: "rgba(66, 92, 117, 1)",
        },
        axisTick: {
          show: false,
          lineStyle: {
            color: 'rgba(61, 61, 64, 1)',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1.5,
            type: 'dashed',
            color: 'rgba(239, 240, 240, 1)',
            //opacity: 0.6,
          },
        },
        splitLine: {
          show: false,
          lineStyle: {
            color: 'rgba(61, 61, 64, 1)',
            //opacity: 0.3,
          },
        },
      },
      {
        type: 'value',
        axisLabel: {
          show: false,
          formatter: '{value}',
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: '#EFF0F0',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1.5,
            type: 'dashed',
            color: '#EFF0F0',
            //opacity: 0.6,
          },
        },
        splitLine: {
          lineStyle: {
            color: '#EFF0F0',
            //opacity: 0.3,
          },
        },
      },
    ],
    series: [
      {
        name: 'awake',
        stack: 'Total',
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(202, 215, 214, 0.88)',
            },
            {
              offset: 1,
              color: 'rgba(202, 215, 214, 0)',
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: 'rgba(202, 215, 214, 1)',
        },
        lineStyle: {
          type: 'solid'
        },
        data: awake,
      },
      {
        name: 'awake',
        stack: 'Total2',
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(202, 215, 214, 0.88)',
            },
            {
              offset: 1,
              color: 'rgba(202, 215, 214, 0)',
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: 'rgba(202, 215, 214, 1)',
        },
        lineStyle: {
          type: 'dotted'
        },
        data: awake2,
      },
      {
        name: 'light',
        stack: 'Total',
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(75, 168, 142, 1)',
            },
            {
              offset: 1,
              color: 'rgba(75, 168, 142, 0.2)',
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: 'rgba(75, 168, 142, 1)',
        },
        data: light,
      },
      {
        name: 'light',
        stack: 'Total2',
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(75, 168, 142, 0.87)',
            },
            {
              offset: 1,
              color: 'rgba(75, 168, 142, 0.2)',
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: 'rgba(75, 168, 142, 1)',
        },
        lineStyle: {
          type: 'dotted'
        },
        data: light2,
      },
      {
        name: 'deep',
        stack: 'Total',
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(38, 84, 166, 0.9)',
            },
            {
              offset: 1,
              color: 'rgba(38, 84, 166, 0.2)',
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: 'rgba(38, 84, 166, 1)',
        },
        data: deep,
      },
      {
        name: 'deep',
        stack: 'Total2',
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(38, 84, 166, 0.9)',
            },
            {
              offset: 1,
              color: 'rgba(38, 84, 166, 0.2)',
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: 'rgba(38, 84, 166, 1)',
        },
        lineStyle: {
          type: 'dotted'
        },
        data: deep2,
      },
    ],
  };
  chart.setOption(option2);
  chart.resize();
}
//周/月报单系列
function drawmonthchart(chart, value, value1, time, color, color2, color3, color4, interval) {
  let tempinterval = 0;
  if (stage == 'week') {
    tempinterval = 1;
  } else if (stage == 'month') {
    tempinterval = 9;
  } else {
    tempinterval = 120;
  }
  var temp;
  if (model == 'total' || model == 'deep' || model == 'light') {
    temp = 60;
  } else if (model == 'hrv') {
    temp = 0.5;
  } else {
    temp = 1;
  }
  option2 = {
    tooltip: {
      trigger: 'axis',
      // position: function (point, params, dom, rect, size) {
      //   return { bottom: 5 }
      // },
      axisPointer: {
        type: 'none',
      },
      formatter: function (value) {
        //console.log(value)
        var Monthtemp = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Spt", "Oct", "Nov", "Dec"]
        if (model == 'total' || model == 'deep' || model == 'light') {
          if (value[0].data == '-') {
            return 'Sleep report ' + '<br/>' + 'not collected.'
          } else {
            let tempdate = value[0].axisValue.split('/')
            let tempdate_1 = parseInt(tempdate[0])
            let a =
              Math.floor(value[0].data / 60) +
              ' h ' +
              (value[0].data % 60) +
              ' min';
            return Monthtemp[tempdate_1 - 1] + ' ' + tempdate[1] + "<br/>" + value[0].marker + a;
          }
        }
        //else if(value==''){} 
        else {
          if (value[0].data == '-') {
            return 'Sleep report ' + '<br/>' + 'not collected.'
          } else {
            let tempdate = value[0].axisValue.split('/')
            let tempdate_1 = parseInt(tempdate[0])
            let lab = ""
            if (model == 'heart') {
              lab = ' bpm'
            } else if (model == "breath") {
              lab = ' breaths/min'
            } else if (model == "hrv") {
              lab = ' ms'
            } else if (model == 'snore') {
              lab = ' times'
            } else if (model == 'move') {
              lab = ' movements'
            } else if (model == "outbed") {
              lab = value[0].data == 1 ? " time" : " times"
            }
            //console.log('a===>', value)
            return Monthtemp[tempdate_1 - 1] + ' ' + tempdate[1] + "<br/>" + value[0].marker + value[0].data + lab;
          }

        }
      },
    },
    grid: {
      top: '12%',
      right: '3%',
      bottom: '10%',
      left: '12%',
    },
    xAxis: {
      type: 'category',
      data: time,
      boundaryGap: false,
      axisTick: {
        show: false,
      },
      axisLabel: {
        // formatter: function (value, index) {
        //   let temp = [];
        //   temp.push(index);
        //   const count = temp[temp.length - 1];
        //   if (index === 0) {
        //     if (stage == 'year') {
        //       let num = parseInt(value.substring(0, 2));
        //       return '            ' + MonthArr[num - 1];
        //     } else {
        //       return '            ' + value;
        //     }
        //   } else if (index === count) {
        //     if (stage == 'year') {
        //       let num = parseInt(value.substring(0, 2));
        //       return MonthArr[num - 1] + '            ';
        //     } else {
        //       return value + '            ';
        //     }
        //   } else {
        //     if (stage == 'year') {
        //       let num = parseInt(value.substring(0, 2));
        //       return MonthArr[num - 1];
        //     } else {
        //       return value;
        //     }
        //   }
        // },
        showMaxLabel: false,
        showMinLabel: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        //opacity: 0.5,
        interval: tempinterval,
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'DM Sans',
        // align: 'left',
        show: false,
      },
      axisLine: {
        lineStyle: {
          color: '#EFF0F0',
          width: 1.3,
          //opacity: 0.5,
        },
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#EFF0F0',
          //opacity: 0.3,
        },
      },
    },
    yAxis: [
      {
        name: '',
        nameLocation: 'end',
        nameTextStyle: {
          fontSize: getDpr() * 1.2,
          padding: 2,
          align: 'center',
        },
        minInterval: temp,
        splitNumber: 3,
        // data: [1, 2, 3, 4, 5, 6, 7, 8],
        type: 'value',
        axisLabel: {
          formatter: function (value) {
            if (model == 'total' || model == 'deep' || model == 'light') {
              let a = Math.round(value / 60);
              return a;
            } else {
              return value;
            }
          },
          fontSize: 14,
          fontWeight: '400',
          fontFamily: 'DM Sans',
          // color: '#093147',
          color: "rgba(66, 92, 117, 1)",
        },
        axisTick: {
          show: false,
          lineStyle: {
            color: 'rgba(61, 61, 64, 1)',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1.5,
            type: 'dashed',
            color: 'rgba(239, 240, 240, 1)',
            //opacity: 0.6,
          },
        },
        splitLine: {
          show: false,
          lineStyle: {
            color: 'rgba(61, 61, 64, 1)',
            //opacity: 0.3,
          },
        },
      },
      {
        type: 'value',
        axisLabel: {
          show: false,
          formatter: '{value}',
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: '#EFF0F0',
            //opacity: 0.3,
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            width: 1.5,
            type: 'dashed',
            color: '#EFF0F0',
            //opacity: 0.6,
          },
        },
        splitLine: {
          lineStyle: {
            color: '#EFF0F0',
            //opacity: 0.3,
          },
        },
      },
    ],
    series: [
      {
        name: 'deep',
        data: value,
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: color,
            },
            {
              offset: 1,
              color: color2,
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        itemStyle: {
          color: color3,
        },
      },
      {
        name: 'deep2',
        data: value1,
        // barWidth: '10%',
        type: 'line',
        symbol: 'none',
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: color4,
            },
            {
              offset: 1,
              color: color3,
            },
          ]),
        },
        emphasis: {
          focus: 'series',
        },
        lineStyle: {
          type: 'dotted'
        },
        itemStyle: {
          color: color3,
        },
      },
    ],
  };
  chart.setOption(option2);
  chart.resize();
}
function drawheartchart(chart, value, time, max, min, interval) {
  tmparr = [];
  option = {
    title: {
      text: '',
    },
    tooltip: {
      // enterable: true,
      trigger: 'axis',
      axisPointer: {
        type: 'none',
      },
      formatter: function (value) {
        return value[0].data + " bpm";
      },
    },
    grid: {
      left: '15%',
      right: '5%',
      top: '5%',
      bottom: '20%',
    },
    xAxis: {
      type: 'category',
      data: time,
      boundaryGap: false,
      splitNumber: 'auto',
      axisLine: {
        lineStyle: {
          color: 'rgba(239,240,240,1)',
          type: 'solid',
        },
      },
      axisLabel: {
        show: false,
        // interval: interval,
        showMinLabel: false,
        showMaxLabel: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        fontSize: 14,
        fontWeight: 400,
        fontFamily: 'DM Sans',
        formatter: function (value) {
          var date = new Date(parseInt(value));
          var y = date.getFullYear();
          var m = date.getMonth() + 1;
          var d = date.getDate();
          var h = date.getHours();
          var min = date.getMinutes();
          var s = date.getSeconds();
          var re = '';
          min = min > 9 ? min : '0' + min;
          if (h > 12) {
            if (timetype == 12) {
              h = h - 12;
              temp = h;
              re = h + 'PM';
              h = h + ':' + min + 'PM';
              // if (temp != 0 && temp % 2 == 0) {
              //   if (h.substring(h.length - 4, h.length - 2) == '00') {
              if (!tmparr.includes(re)) {
                tmparr.push(re);
                return re;
              }
              //   }
              return re;
              // }
            } else {
              temp = h;
              re = h;
              h = h + ':' + min;
              // if (temp != 0 && temp % 2 == 0) {
              if (!tmparr.includes(re)) {
                tmparr.push(re);
                return re;
              }
              return h;
              // }
            }
          } else {
            if (h == 0) {
              if (timetype == 12) {
                h = 12;
                temp = h;
                re = h + 'AM';
                h = h + ':' + min + 'AM';
                // if (temp != 0 && temp % 2 == 0) {
                //   if (h.substring(h.length - 4, h.length - 2) == '00') {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                //   }
                return re;
                // }
              } else {
                temp = h;
                re = h;
                h = h + ':' + min;
                // if (temp != 0 && temp % 2 == 0) {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                return h;
                // }
              }
            } else {
              if (timetype == 12) {
                temp = h;
                re = h + 'AM';
                h = h + ':' + min + 'AM';
                // if (temp != 0 && temp % 2 == 0) {
                //   if (h.substring(h.length - 4, h.length - 2) == '00') {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                //   }
                return re;
                // }
              } else {
                re = h;
                h = h + ':' + min;
                // if (temp != 0 && temp % 2 == 0) {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                return h;
                // }
              }
            }
          }
        },
      },
      splitLine: {
        show: false,
      },
      axisTick: {
        show: false,
      },
    },
    yAxis: {
      type: 'value',
      min: min,
      max: max,
      splitNumber: 5,
      axisLabel: {
        margin: 20,
        show: true,
        // interval: interval,
        formatter: '{value}',
        showMinLabel: true,
        showMaxLabel: true,
        fontSize: 14,
        fontWeight: 400,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
      },
      axisLine: {
        show: true,
        lineStyle: {
          show: false,
          type: 'dashed',
          color: 'rgba(239,240,240,1)',
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: 'rgba(239,240,240,1)',
        },
      },
      axisTick: {
        show: false,
      },
    },
    series: {
      type: 'line',
      data: value,
      symbol: 'none',
      smooth: true,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(219, 74, 106, 0.8)',
          },
          {
            offset: 1,
            color: 'rgba(219, 74, 106, 0.2)',
          },
        ]),
      },
      emphasis: {
        focus: 'series',
      },
      itemStyle: {
        color: 'rgba(219, 74, 106, 1)',
      },
      // areaStyle: {},
    },
  };
  chart.setOption(option);
  chart.resize();
}
function drawbreathchart(chart, value, time, max) {
  option = {
    title: {
      text: '',
    },
    tooltip: {
      // enterable: true,
      trigger: 'axis',
      axisPointer: {
        type: 'none',
      },
      formatter: function (value) {
        return value[0].data + ' breaths/min';
      },
    },
    grid: {
      left: '15%',
      right: '5%',
      top: '5%',
      bottom: '20%',
    },
    xAxis: {
      type: 'category',
      data: time,
      boundaryGap: false,
      axisLine: {
        lineStyle: {
          color: 'rgba(239,240,240,1)',
          type: 'solid',
        },
      },
      axisLabel: {
        show: false,
        // interval: interval,
        showMinLabel: false,
        showMaxLabel: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        fontSize: 14,
        fontWeight: 400,
        formatter: function (value) {
          var date = new Date(parseInt(value));
          var y = date.getFullYear();
          var m = date.getMonth() + 1;
          var d = date.getDate();
          var h = date.getHours();
          var min = date.getMinutes();
          var s = date.getSeconds();
          var re = '';
          min = min > 9 ? min : '0' + min;
          if (h > 12) {
            if (timetype == 12) {
              h = h - 12;
              temp = h;
              re = h + 'PM';
              h = h + ':' + min + 'PM';
              // if (temp != 0 && temp % 2 == 0) {
              //   if (h.substring(h.length - 4, h.length - 2) == '00') {
              if (!tmparr.includes(re)) {
                tmparr.push(re);
                return re;
              }
              //   }
              return re;
              // }
            } else {
              temp = h;
              re = h;
              h = h + ':' + min;
              // if (temp != 0 && temp % 2 == 0) {
              if (!tmparr.includes(re)) {
                tmparr.push(re);
                return re;
              }
              return h;
              // }
            }
          } else {
            if (h == 0) {
              if (timetype == 12) {
                h = 12;
                temp = h;
                re = h + 'AM';
                h = h + ':' + min + 'AM';
                // if (temp != 0 && temp % 2 == 0) {
                //   if (h.substring(h.length - 4, h.length - 2) == '00') {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                //   }
                return re;
                // }
              } else {
                temp = h;
                re = h;
                h = h + ':' + min;
                // if (temp != 0 && temp % 2 == 0) {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                return h;
                // }
              }
            } else {
              if (timetype == 12) {
                temp = h;
                re = h + 'AM';
                h = h + ':' + min + 'AM';
                // if (temp != 0 && temp % 2 == 0) {
                //   if (h.substring(h.length - 4, h.length - 2) == '00') {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                //   }
                return re;
                // }
              } else {
                re = h;
                h = h + ':' + min;
                // if (temp != 0 && temp % 2 == 0) {
                if (!tmparr.includes(re)) {
                  tmparr.push(re);
                  return re;
                }
                return h;
                // }
              }
            }
          }
        },
      },
      splitLine: {
        show: false,
      },
      axisTick: {
        show: false,
      },
    },
    yAxis: {
      type: 'value',
      max: max,
      min: 0,
      splitNumber: 5,
      axisLabel: {
        show: true,
        formatter: '{value}',
        showMinLabel: true,
        showMaxLabel: true,
        fontSize: 14,
        fontWeight: 400,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
      },
      axisLine: {
        show: true,
        lineStyle: {
          show: false,
          type: 'dashed',
          color: 'rgba(239,240,240,1)',
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: 'rgba(239,240,240,1)',
        },
      },
      axisTick: {
        show: false,
      },
    },
    series: {
      type: 'line',
      data: value,
      symbol: 'none',
      smooth: true,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(111, 148, 216, 0.8)',
          },
          {
            offset: 1,
            color: 'rgba(111, 148, 216, 0.2)',
          },
        ]),
      },
      emphasis: {
        focus: 'series',
      },
      itemStyle: {
        color: 'rgba(111, 148, 216, 1)',
      },
    },
  };
  chart.setOption(option);
  chart.resize();
}
//打鼾报告（日）{
function drawsnorechart(chart, snore, color) {
  option1 = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'none',
      },
      formatter: function (value) {
        let time = dateformat(value[0].data[0], 0, 1);
        return time.substring(11, 16) + ' ' + time.substring(5, 11) + " times";
      },
    },
    grid: {
      top: '10%',
      right: '5%',
      left: '16%',
      bottom: '20%',
    },
    xAxis: {
      type: 'time',
      boundaryGap: false,
      axisTick: {
        show: false,
      },
      splitNumber: 5,
      axisLabel: {
        // show: false,
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
        //opacity: 0.5,
        showMaxLabel: true,
        showMinLabel: true,
        fontSize: 14,
        fontWeight: 'bold',
        fontFamily: 'DM Sans',
        formatter: function (value) {
          var date = new Date(value);
          var y = date.getFullYear();
          var m = date.getMonth() + 1;
          var d = date.getDate();
          var h = date.getHours();
          var min = date.getMinutes();
          var s = date.getSeconds();
          var re = '';
          min = min > 9 ? min : '0' + min;
          if (h > 12) {
            h = h - 12;
            re = h + ' PM';
            h = h + ':' + min + 'PM';
          } else {
            if (h == 0) {
              h = 12;
              re = h + ' AM';
              h = h + ':' + min + 'AM';
            } else {
              re = h + ' AM';
              h = h + ':' + min + 'AM';
            }
          }
          if (h.substring(h.length - 4, h.length - 2) == '00') {
            return re;
          }
        },
      },
      axisLine: {
        lineStyle: {
          color: '#F2F6FE',
          width: 1.3,
          //opacity: 0.5,
        },
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#F2F6FE',
          //opacity: 0.3,
        },
      },
    },
    yAxis: {
      type: 'value',
      max: 1,
      splitNumber: 1,
      boundaryGap: false,
      // interval: interval,
      axisLabel: {
        show: true,
        // interval: interval,
        formatter: '{value}',
        showMinLabel: true,
        fontSize: 14,
        fontWeight: 'bold',
        // color: '#093147',
        color: "rgba(66, 92, 117, 1)",
      },
      axisLine: {
        show: true,
        lineStyle: {
          show: false,
          type: 'dashed',
          color: 'rgba(239,240,240,1)',
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: 'rgba(239,240,240,1)',
        },
      },
      axisTick: {
        show: false,
      },
    },
    series: [
      {
        data: snore,
        type: 'bar',
        barCategoryGap: '0%',
        smooth: true,
        lineStyle: {
          color: color,
          width: 1,
        },
        itemStyle: {
          color: color,
        },
      },
    ],
  };
  chart.setOption(option1);
  chart.resize();
}
